/**
 * 获取数据字典
 * @param type => default, icsr, adr, area
 */
function getDict(type = 'default') {
  return JSON.parse(localStorage.getItem(`${process.env.PROJECT_CODE}_dict_${type}`)) || {};
}

/**
 * 设置数据字典
 */
function setDict(defaultDict = {}, icsrDict = {}, adrDict = {}, areaDict = {}) {
  localStorage.setItem(`${process.env.PROJECT_CODE}_dict_default`, JSON.stringify(defaultDict));

  localStorage.setItem(`${process.env.PROJECT_CODE}_dict_icsr`, JSON.stringify(icsrDict));

  localStorage.setItem(`${process.env.PROJECT_CODE}_dict_adr`, JSON.stringify(adrDict));

  localStorage.setItem(`${process.env.PROJECT_CODE}_dict_area`, JSON.stringify(areaDict));
}

export { getDict, setDict };
